<!doctype html>



  


<html class="theme-next muse use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|consolas:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="HongqinMa, Hiraku, web前端, web全栈, javascript, html, css, nodejs" />








  <link rel="shortcut icon" type="image/x-icon" href="http://ofy7k3v4s.bkt.clouddn.com/mylogo.png?v=5.0.2" />






<meta name="description" content="Spell at all costs， to rush you in the future.">
<meta property="og:type" content="website">
<meta property="og:title" content="HongqinMa' Blog">
<meta property="og:url" content="https://hongqinma.github.io/page/2/index.html">
<meta property="og:site_name" content="HongqinMa' Blog">
<meta property="og:description" content="Spell at all costs， to rush you in the future.">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="HongqinMa' Blog">
<meta name="twitter:description" content="Spell at all costs， to rush you in the future.">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6347850919329138000',
      author: 'Hiraku'
    }
  };
</script>




  <link rel="canonical" href="https://hongqinma.github.io/page/2/"/>


  <title> HongqinMa' Blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?10010323";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  
    <div class="site-meta-headline">
      <a>
        <img class="custom-logo-image" src="http://ofy7k3v4s.bkt.clouddn.com/photo.jpg"
             alt="HongqinMa' Blog"/>
      </a>
    </div>
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">HongqinMa' Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Spell at all costs， to rush you in the future。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/10/23/s010-node-相册小项目（下）/" itemprop="url">
                  Node-相册小项目（下）
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-10-23T21:29:52+08:00" content="2016-10-23">
              2016-10-23
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/10/23/s010-node-相册小项目（下）/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/10/23/s010-node-相册小项目（下）/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x5C06;&#x76F8;&#x518C;&#x9879;&#x76EE;&#xFF08;&#x4E2D;&#xFF09;&#x7EE7;&#x7EED;&#x5347;&#x7EA7;&#xFF0C;&#x6700;&#x7EC8;&#x4F7F;&#x7528; Express &#x7248;&#x672C;&#x3002;
&#x5C01;&#x88C5; render &#x6E32;&#x67D3;&#x51FD;&#x6570;
&#x83B7;&#x53D6;&#x6A21;&#x677F;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x9700;&#x8981;&#x7684;&#x6570;&#x636E;
&#x83B7;&#x53D6;&#x6A21;&#x677F;&#x5B57;&#x7B26;&#x4E32;
fs.readFile(&apos;&#x6587;&#x4EF6;&#x540D;&apos;);


&#x5C06;&#x6A21;&#x677F;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7528;&#x5230;&#x7684;&#x6570;&#x636E;&#x548C;&#x6A21;&#x677F;&#x5B57;&#x7B26;&#x4E32;&#x901A;&#x8FC7;&#x6A21;&#x677F;&#x5F15;&#x64CE;&#x6574;&#x5408;&#x5230;&#x4E00;&#x8D77;
_.template(&#x6A21;&#x677F;&#x5B57;&#x7B26;&#x4E32;)({&#x6570;&#x636E;&#x5BF9;&#x8C61;});


&#x53D1;&#x9001;&#x54CD;&#x5E94;
res.end(_.template(&#x6A21;&#x677F;&#x5B57;&#x7B26;&#x4E32;)({&#x6570;&#x636E;&#x5BF9;&#x8C61;}));



render(&#x2018;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x2019;, &#x2018;&#x6570;&#x636E;&#x5BF9;&#x8C61;&
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/10/23/s010-node-相册小项目（下）/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/10/18/s009-node-相册小项目（中）/" itemprop="url">
                  Node-相册小项目（中）
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-10-18T21:37:09+08:00" content="2016-10-18">
              2016-10-18
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/10/18/s009-node-相册小项目（中）/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/10/18/s009-node-相册小项目（中）/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x64CD;&#x4F5C;&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F84;&#x4F7F;&#x7528;&#x6CE8;&#x610F;&#x4E8B;&#x9879;&#xFF1A;

&#x5982;&#x679C;&#x662F;&#x4EE5; / &#x5F00;&#x5934;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x5219;&#x5C31;&#x662F;&#x53BB;&#x6267;&#x884C;&#x5F53;&#x524D;&#x811A;&#x672C;&#x6240;&#x5C5E;&#x7684;&#x78C1;&#x76D8;&#x6839;&#x8DEF;&#x5F84;&#x53BB;&#x627E;
&#x5982;&#x679C;&#x662F;&#x4EE5; C:/dev/nvm/settings.txt &#xFF0C;&#x5219;&#x76F4;&#x63A5;&#x53BB;&#x627E;&#x8BE5;&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;
&#x5982;&#x679C;&#x662F;&#x4EE5; ./ &#x6216;&#x8005; ../ &#x5F00;&#x5934;&#x7684;&#xFF0C;&#x5219;&#x662F;&#x76F8;&#x5BF9;&#x4E8E;&#x6267;&#x884C; node &#x547D;&#x4EE4;&#x7684;&#x65F6;&#x5019;&#x6240;&#x5904;&#x7684;&#x8DEF;&#x5F84;

1234567const fs = require(&apos;fs&apos;);fs.readFile(&apos;/README.md&apos;, &apos;utf8&apos;, (err, data) =&gt; {  if (err) {    throw err;  }  console.log(data);});
&#x5982;&#x679C;&#x4F7F;&#x7528; C:\Users\mhq\Desktop&gt; node 
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/10/18/s009-node-相册小项目（中）/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/10/14/s008-node-相册小项目（上）/" itemprop="url">
                  Node-相册小项目（上）
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-10-14T23:22:12+08:00" content="2016-10-14">
              2016-10-14
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/10/14/s008-node-相册小项目（上）/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/10/14/s008-node-相册小项目（上）/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x5B8C;&#x6210;&#x76F8;&#x518C;&#x65B0;&#x5EFA;&#x3001;&#x4E0A;&#x4F20;&#x56FE;&#x7247;&#x7B49;&#x7B80;&#x5355;&#x7684;&#x529F;&#x80FD;&#x5C0F;&#x9879;&#x76EE;&#x3002;
&#x9879;&#x76EE;&#x521D;&#x59CB;&#x5316;
&#x628A;&#x524D;&#x7AEF;&#x7528;&#x5230;&#x7684;&#x9759;&#x6001;&#x8D44;&#x6E90;&#x653E;&#x5230; public &#x76EE;&#x5F55;&#x4E0B;
&#x628A;&#x6240;&#x6709;&#x7684;&#x9875;&#x9762;&#x90FD;&#x653E;&#x5230; views &#x76EE;&#x5F55;&#x4E0B;
&#x5728;&#x9879;&#x76EE;&#x6839;&#x8DEF;&#x5F84;&#x4E0B;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; app.js &#x4F5C;&#x4E3A;&#x540E;&#x53F0;&#x7684;&#x542F;&#x52A8;&#x5165;&#x53E3;
&#x4F7F;&#x7528; npm &#x5B89;&#x88C5;&#x548C;&#x7BA1;&#x7406;&#x9879;&#x76EE;&#x7684;&#x4F9D;&#x8D56;&#x9879;
&#x5C06;&#x6240;&#x6709;&#x7684;&#x76F8;&#x518C;&#x653E;&#x5230;&#x9879;&#x76EE;&#x6839;&#x8DEF;&#x5F84;&#x4E0B;&#x7684; uploads &#x76EE;&#x5F55;&#x5C0F;

&#x5212;&#x5206;&#x54EA;&#x4E9B;&#x8D44;&#x6E90;&#x516C;&#x5171;&#x5F00;&#x653E;
public
css
js
img


uploads
node_modules


          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/10/14/s008-node-相册小项目（上）/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/10/09/s007-node-http-网站/" itemprop="url">
                  Node-http-网站
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-10-09T23:59:36+08:00" content="2016-10-09">
              2016-10-09
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/10/09/s007-node-http-网站/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/10/09/s007-node-http-网站/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x8D85;&#x6587;&#x672C;&#x4F20;&#x8F93;&#x534F;&#x8BAE;&#xFF08;HTTP&#xFF0C;HyperText Transfer Protocol)&#x662F;&#x4E92;&#x8054;&#x7F51;&#x4E0A;&#x5E94;&#x7528;&#x6700;&#x4E3A;&#x5E7F;&#x6CDB;&#x7684;&#x4E00;&#x79CD;&#x7F51;&#x7EDC;&#x534F;&#x8BAE;

&#x63A5;&#x6536;&#x8BF7;&#x6C42;
&#x5904;&#x7406;&#x8BF7;&#x6C42;
&#x53D1;&#x9001;&#x54CD;&#x5E94;

net &#x4E3A;&#x4EC0;&#x4E48;&#x4E0D;&#x80FD;&#x5904;&#x7406;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x54CD;&#x5E94;&#x5462;&#xFF1F;
http &#x6A21;&#x5757;&#x548C; net &#x6A21;&#x5757;&#x4E4B;&#x95F4;&#x7684;&#x533A;&#x522B;
http &#x6A21;&#x5757;&#x7684;&#x7B80;&#x5355;&#x4F7F;&#x7528;(1). &#x521B;&#x5EFA;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x5F97;&#x5230;&#x4E00;&#x4E2A; Server &#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;

&#x4EFB;&#x4F55;&#x8BF7;&#x6C42;&#x90FD;&#x4F1A;&#x89E6;&#x53D1;&#x8BE5; request &#x8BF7;&#x6C42;&#x4E8B;&#x4EF6;&#xFF0C;&#x7136;&#x540E;&#x6267;&#x884C;&#x4E8B;&#x4EF6;&#x5904;&#x7406;&#x51FD;&#x6570;
&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6240;&#x6
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/10/09/s007-node-http-网站/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/10/02/s006-node-网络编程-终端聊天室/" itemprop="url">
                  Node-网络编程-终端聊天室
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-10-02T22:12:05+08:00" content="2016-10-02">
              2016-10-02
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/10/02/s006-node-网络编程-终端聊天室/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/10/02/s006-node-网络编程-终端聊天室/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x7F51;&#x7EDC;&#x7F16;&#x7A0B;
&#x5E94;&#x7528;&#x5C42;
http &#x534F;&#x8BAE;
&#x5728;&#x6D4F;&#x89C8;&#x5668;&#x8F93;&#x5165;&#x4E00;&#x4E2A;&#x5730;&#x5740;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x6309;&#x7167; http &#x534F;&#x8BAE;&#x5C06;&#x8F93;&#x5165;&#x7684;&#x5730;&#x5740;&#x5305;&#x88C5;&#x6210; http &#x62A5;&#x6587;
&#x548C;&#x6570;&#x636E;&#x4F20;&#x8F93;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x5173;&#x7CFB;
&#x53EA;&#x8D1F;&#x8D23;&#x6570;&#x636E;&#x5305;&#x88C5;
&#x5305;&#x88C5;&#x76EE;&#x7684;&#x5C31;&#x662F;&#x4E3A;&#x4E86;&#x533A;&#x5206;&#x4E0D;&#x540C;&#x7684;&#x884C;&#x4E3A;


&#x4F20;&#x8F93;&#x5C42;
&#x5C06;&#x5E94;&#x7528;&#x5C42;&#x5305;&#x88C5;&#x597D;&#x7684;&#x6570;&#x636E;&#xFF0C;&#x901A;&#x8FC7;&#x4F20;&#x8F93;&#x5C42;&#x8FDB;&#x884C;&#x4F20;&#x8F93;
TCP: &#x7535;&#x8BDD;&#x673A; 
&#x7AEF;&#x5230;&#x7AEF;&#x901A;&#x4FE1;&#x534F;&#x8BAE;&#xFF0C;&#x5FC5;&#x987B;&#x77E5;&#x9053;&#x5BF9;&#x65B9;&#x7684; ip &#x5730;&#x5740;&#x548C;&#x7AEF;&#x53E3;&#x53F7;
TCP/IP &#x5BF9;&
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/10/02/s006-node-网络编程-终端聊天室/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/09/27/s005-node-文件操作（下）-文件监视、markdown转换器/" itemprop="url">
                  Node-文件操作（下）- 文件监视、markdown转换器
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-09-27T23:41:42+08:00" content="2016-09-27">
              2016-09-27
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/09/27/s005-node-文件操作（下）-文件监视、markdown转换器/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/09/27/s005-node-文件操作（下）-文件监视、markdown转换器/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x76D1;&#x89C6;&#x6587;&#x4EF6;&#x76D1;&#x89C6; API fs.watchFile()

&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x4E2D;&#x9700;&#x8981;&#x63A5;&#x6536;&#x4E24;&#x4E2A;&#x53C2;&#x6570;
&#x7B2C;&#x4E00;&#x4E2A;&#x662F;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x7684;&#x6700;&#x65B0;&#x72B6;&#x6001; stat&#xFF0C;
&#x7B2C;&#x4E8C;&#x4E2A;&#x662F;&#x53D8;&#x5316;&#x4E4B;&#x524D;&#x7684; stat

123456const fs = require(&apos;fs&apos;);// &#x76D1;&#x89C6;&#x6587;&#x4EF6;&#x7684;&#x4FEE;&#x6539;&#x65F6;&#x95F4;fs.watchFile(&apos;./node.md&apos;, (curr, prev) =&gt; {  console.log(curr.mtime.getHours() + &apos;:&apos; + curr.mtime.getMinutes() + &apos;:&apos; +curr.mtime.getSeconds());  console.log(prev.mtime.getHours() + &apos;:&apos; + prev.mtime.getMinutes() + &apos;:&apos; +prev.mtime.getSeconds());});
&#x4F7F;&#x7528;&#x6A21;&#x677F;&#x5F15;&#x64CE;&#x65F6;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x5730;&#x65B9;
1234567891011const template = require(&apos;art-template&apos;);// 1. &#x8C03;&#x7528; template.comp
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/09/27/s005-node-文件操作（下）-文件监视、markdown转换器/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/09/24/s004-node-文件操作（中）-文件状态、promise版本封装/" itemprop="url">
                  Node-文件操作（中）- 文件状态、promise版本封装
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-09-24T22:30:52+08:00" content="2016-09-24">
              2016-09-24
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/09/24/s004-node-文件操作（中）-文件状态、promise版本封装/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/09/24/s004-node-文件操作（中）-文件状态、promise版本封装/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x4FE1;&#x606F;123const fs = require(&apos;fs&apos;);fs.stat(path,callback);
&#x6587;&#x4EF6;&#x76EE;&#x5F55;readdir &#x53EA;&#x80FD;&#x8BFB;&#x53D6;&#x4E00;&#x7EA7;&#x76EE;&#x5F55;
1. readdir &#x65B9;&#x6CD5;&#x521D;&#x6B65;&#x4F7F;&#x7528;12345678910111213141516171819const fs = require(&apos;fs&apos;);const path = require(&apos;path&apos;);fs.readdir(rootDir, (err, data) =&gt; {  if (err) {    throw err;  }  for(let name of files) {    const tmpPath = path.join(rootDir, name);    fs.stat(tmpPath, (err, stats) =&gt; {      if (err) {        throw err;      }      if (stats.isFile() &amp;&amp; path.extname(tmpPath) === &apos;.cmd&apos;) {        console.log(tempPath);      }    });  }});
2. &#x628A; 1 &#x7684;&#x4EE3;&#x7801;&#x5C01;&#x88C5;&#x6210;&#x4E00;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#x4E0B;&#x6240;&#x6709;&#x540E;&#x7F00;&#x540D;&#x7684;&#x6587;&#x4EF6;123456789101112131415161718192021222324252627282
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/09/24/s004-node-文件操作（中）-文件状态、promise版本封装/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/09/19/s003-node-promise-对象/" itemprop="url">
                  Node-promise 对象
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-09-19T21:45:21+08:00" content="2016-09-19">
              2016-09-19
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/09/19/s003-node-promise-对象/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/09/19/s003-node-promise-对象/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          &#x4E00;&#x4E2A; promise &#x5728;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x4F53;&#x73B0;&#x51FA;&#x6765;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x8BE5;&#x5BF9;&#x8C61;&#x4E00;&#x822C;&#x4FDD;&#x5B58;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7684;&#x4EFB;&#x52A1;&#x3002;
Promise&#x662F;&#x5F02;&#x6B65;&#x7F16;&#x7A0B;&#x7684;&#x4E00;&#x79CD;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#xFF0C;&#x6BD4;&#x4F20;&#x7EDF;&#x7684;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#x2014;&#x2014;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x548C;&#x4E8B;&#x4EF6;&#x2014;&#x2014;&#x66F4;&#x5408;&#x7406;&#x548C;&#x66F4;&#x5F3A;&#x5927;&#x3002;&#x5B83;&#x7531;&#x793E;&#x533A;&#x6700;&#x65E9;&#x63D0;&#x51FA;&#x548C;&#x5B9E;&#x73B0;&#xFF0C;ES6&#x5C06;&#x5176;&#x5199;&#x8FDB;&#x4E86;&#x8BED;&#x8A00;&#x6807;&#x51C6;&#xFF0C;&#x7EDF;&#x4E00;&#x4E86;&#x7528;&#x6CD5;&#xFF0C;&#x539F;&#x751F;&#x63D0;&#x4F9B;&#x4E86; Promise &#x5BF9;&#x8C61;&#x3002;&#x8868;&#x793A;&#x662F;&#x4E00;&#x4E2A;&#x672A;&#x6765;&#x7684;&#x4E8B;&#x60C5;&#x
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/09/19/s003-node-promise-对象/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/09/15/s002-node-文件操作（上）-简单封装复制文件方法、process对象/" itemprop="url">
                  Node-文件操作（上）-简单封装复制文件方法、process对象
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-09-15T19:40:41+08:00" content="2016-09-15">
              2016-09-15
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/09/15/s002-node-文件操作（上）-简单封装复制文件方法、process对象/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/09/15/s002-node-文件操作（上）-简单封装复制文件方法、process对象/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          fs &#x6587;&#x4EF6;&#x64CD;&#x4F5C;&#x6A21;&#x5757;
Node &#x53EA;&#x5728;&#x6587;&#x4EF6; IO &#x64CD;&#x4F5C;&#x4E2D;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x540C;&#x6B65;&#x8C03;&#x7528;&#x548C;&#x5F02;&#x6B65;&#x8C03;&#x7528;&#x4E24;&#x79CD;&#x5F62;&#x5F0F;&#xFF0C;fs &#x6A21;&#x5757;&#x5BF9;&#x6587;&#x4EF6;&#x7684;&#x51E0;&#x4E4E;&#x6240;&#x6709;&#x64CD;&#x4F5C;&#x90FD;&#x6709;&#x540C;&#x6B65;&#x548C;&#x5F02;&#x6B65;&#x4E24;&#x79CD;&#x5F62;&#x5F0F;&#xFF0C;&#x4E24;&#x8005;&#x53EF;&#x4EE5;&#x7ED3;&#x5408;&#x4F7F;&#x7528;&#xFF0C;&#x4F46;&#x662F;&#x63A8;&#x8350;&#x80FD;&#x4F7F;&#x7528;&#x5F02;&#x6B65;&#x8C03;&#x7528;&#x89E3;&#x51B3;&#x95EE;&#x9898;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5C11;&#x7528;&#x540C;&#x6B65;&#x8C03;&#x7528;&#x3002;
&#x4F8B;&#x5982;&#xFF1A;readFile() &#x548C; readFileSync()&#x3002;
&#x5F15;&#x5165;&#x5305;1const path = require(&apos;path&apos;);
&#x540C;&#x6B65;&#x64CD;&#x4F5C;
&#x540C;&#x6B65;&#x4EE3;&#x7801;&#x4F1A;&#x963B;&#x585E;&#x540E;&#x7EED;&#x4EE3;&#x7801;&#
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/09/15/s002-node-文件操作（上）-简单封装复制文件方法、process对象/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/09/13/s001-node-node常用API/" itemprop="url">
                  Node常用API
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2016-09-13T19:33:06+08:00" content="2016-09-13">
              2016-09-13
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Node-js/" itemprop="url" rel="index">
                    <span itemprop="name">Node.js</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/09/13/s001-node-node常用API/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/09/13/s001-node-node常用API/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
          path &#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x5904;&#x7406;&#x6A21;&#x5757;&#x5F15;&#x5165;&#x5305;1const path = require(&apos;path&apos;);
path &#x6587;&#x4EF6;&#x8DEF;&#x5F84;&#x5904;&#x7406;&#x7684;&#x76F8;&#x5173; API
path.basename(path[, ext]): &#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x540D;&#x90E8;&#x5206;
path.dirname(path): &#x83B7;&#x53D6;&#x76EE;&#x5F55;&#x90E8;&#x5206;
path.extname(path): &#x83B7;&#x53D6;&#x6269;&#x5C55;&#x540D;&#x90E8;&#x5206;
path.isAbsolute(path): &#x5224;&#x65AD;&#x662F;&#x5426;&#x662F;&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;
path.join([&#x2026;paths]): &#x5C06;&#x591A;&#x4E2A;&#x8DEF;&#x5F84;&#x62FC;&#x63A5;&#x4E3A;&#x4E00;&#x4E2A;&#x8DEF;&#x5F84;
path.normalize(path): &#x5C06;&#x4E00;&#x4E2A;&#x975E;&#x6807;&#x51C6;&#x8DEF;&#x5F84;&#x8F6C;&#x4E3A;&#x4E00;&#x4E2A;&#x6807;&#x51C6;&#x8DEF;&#x5F84;
path.resolve([&#x2026;paths]): &#x5C06;&#x591A;&#x4E2A;&#x8DEF;&#x5F84;&#x62FC;&#x63A5;&#x4E3A;&#x4E00;&#x4E2A;&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;
path.sep: &#x83B7;&#x53D6;&#x64CD;&#x
          ...

          <div class="post-more-link text-center">
            <a class="btn" href="/2016/09/13/s001-node-node常用API/#more" rel="contents">
              Read more &raquo;
            </a>
          </div>
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><a class="extend next" rel="next" href="/page/3/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel  sidebar-panel-active ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/photo.jpg"
               alt="Hongqin Ma" />
          <p class="site-author-name" itemprop="name">Hongqin Ma</p>
          <p class="site-description motion-element" itemprop="description">Spell at all costs， to rush you in the future. </p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">68</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">57</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/HongqinMa" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/HongqinMa" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/profile.php?id=100006581058735" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-facebook"></i>
                  
                  Facebook
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/HirakuMa" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-share-alt"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/rubylouvre/" title="司徒正美" target="_blank">司徒正美</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/sanshi/" title="三生石上" target="_blank">三生石上</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/TomXu/" title="汤姆大叔" target="_blank">汤姆大叔</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://gold.xitu.io/" title="掘金" target="_blank">掘金</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://segmentfault.com/" title="segmentfault" target="_blank">segmentfault</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jianshu.com/users/1cbb94e5ed4d/latest_articles" title="简书" target="_blank">简书</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://home.cnblogs.com/" title="博客园" target="_blank">博客园</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.awesomes.cn/" title="Awesomes" target="_blank">Awesomes</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Hongqin Ma</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv">
    &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Page Views: <span id="busuanzi_value_site_pv"></span> 
</span>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
  

  
    <span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"Hiraku"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  <!-- custom analytics part create by xiamo -->
<script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
<script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
<script>
function showTime(Counter) {
  var query = new AV.Query(Counter);
  $(".leancloud_visitors").each(function() {
    var url = $(this).attr("id").trim();
    query.equalTo("url", url);
    query.find({
      success: function(results) {
        if (results.length == 0) {
          var content = '0 ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
          return;
        }
        for (var i = 0; i < results.length; i++) {
          var object = results[i];
          var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
        }
      },
      error: function(object, error) {
        console.log("Error: " + error.code + " " + error.message);
      }
    });

  });
}

function addCount(Counter) {
  var Counter = AV.Object.extend("Counter");
  url = $(".leancloud_visitors").attr('id').trim();
  title = $(".leancloud_visitors").attr('data-flag-title').trim();
  var query = new AV.Query(Counter);
  query.equalTo("url", url);
  query.find({
    success: function(results) {
      if (results.length > 0) {
        var counter = results[0];
        counter.fetchWhenSave(true);
        counter.increment("time");
        counter.save(null, {
          success: function(counter) {
            var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(counter, error) {
            console.log('Failed to save Visitor num, with error message: ' + error.message);
          }
        });
      } else {
        var newcounter = new Counter();
        newcounter.set("title", title);
        newcounter.set("url", url);
        newcounter.set("time", 1);
        newcounter.save(null, {
          success: function(newcounter) {
              console.log("newcounter.get('time')="+newcounter.get('time'));
            var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(newcounter, error) {
            console.log('Failed to create');
          }
        });
      }
    },
    error: function(error) {
      console.log('Error:' + error.code + " " + error.message);
    }
  });
}
$(function() {
  var Counter = AV.Object.extend("Counter");
  if ($('.leancloud_visitors').length == 1) {
    addCount(Counter);
  } else if ($('.post-title-link').length > 1) {
    showTime(Counter);
  }
}); 
</script>

  
</body>
</html>
